package araujoCoronelVillamayor.plantasVsZombies.uiWicket

import org.apache.wicket.markup.html.basic.Label
import org.apache.wicket.markup.html.panel.Panel
import org.uqbar.wicket.xtend.WicketExtensionFactoryMethods
import org.uqbar.wicket.xtend.XAttributeModifier
import araujoCoronelVillamayor.plantasVsZombies.appModelsArena.SesionAppModel
import org.uqbar.wicket.xtend.XListView

class EstadoJardinPanel extends Panel {
	extension WicketExtensionFactoryMethods = new WicketExtensionFactoryMethods 

	new(String id, SesionAppModel sesion) {
		super(id)
		this.defaultModel = sesion.asCompoundModel
		
		
		
		
		//-------------------------------------------------------------------------------------//
		//----------------------------------- ESTADO JARDIN -----------------------------------//
		//-------------------------------------------------------------------------------------//
		val listViewJardin = new XListView("resultados") //resultados es el id de la tr
		listViewJardin.model = sesion.jardin.filas.asCompoundModel //no pude acceder desde defaultModel
		listViewJardin.populateItem = [ item |
			item.model = item.modelObject.asCompoundModel


			val plantasLabel = new Label("cantidadPlantas")


//			EJERCICIO-----------------------------------------------------------------
//			
//			val saldoLabel = new Label("saldo")
//			saldoLabel.addBehavior(new XAttributeModifier("class", [Float saldo | if (saldo < 0) "saldoNegativo" else ""]))
//			this.addChild(saldoLabel)
//
//			EJERCICIO-----------------------------------------------------------------			


//			plantasLabel.addBehavior(new XAttributeModifier("class", [Integer cantidadPlantas | "span" + cantidadPlantas.toString ]))
//			plantasLabel.addBehavior(new XAttributeModifier("class", [int cantidadPlantas | if (cantidadPlantas > 0) "span6 alert alert-info" else "span1 alert alert-info"]))


			item.addChild(plantasLabel)


		]
		this.addChild(listViewJardin);
		//-------------------------------------------------------------------------------------//
		//----------------------------------- ESTADO JARDIN -----------------------------------//
		//-------------------------------------------------------------------------------------//		
		
		
		
	}
	
}